package ch.axon.demo.stateless;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import ch.axon.demo.entity.Book;

@Stateless
public class BookDao {
	@PersistenceContext (unitName = "xpay_ds")
	private EntityManager em;
	
	//private List<String> books = new ArrayList<String>();
	public void addBook(String name) {
		Book b = new Book();
		b.setBookName(name);
		em.persist(b);
	}
	
	public List<Book> getBooks() {
		return em.createQuery("select b from Book b", Book.class).getResultList();
	}
	
}
